home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / tdk_v120.zip / _SIO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-07-15  |  4KB  |  113 lines

  1. {
  2.  ▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀    ▀▀   ▀▀
  3.    ▀▀     ▀▀   ▀▀   ▀▀  ▀▀
  4.   ▀▀     ▀▀   ▀▀▀  ▀▀▀▀▀  The DoorKit!
  5.  ▀▀     ▀▀   ▀▀   ▀▀  ▀▀
  6. ▀▀     ▀▀▀▀▀▀    ▀▀    ▀▀
  7. The BBS Door Development Kit By The People - For The People!
  8.  
  9.  
  10.    Feel free to modify or optimize this code at will. All I ask is that if
  11.    find a better way to do things (and you will), please send me a copy of
  12.    your modifications. Thanks in advance!....Larry L. Athey....}
  13.  
  14. UNIT _SIO;
  15.  
  16. { Including this unit in your main program source code allows you to use
  17.   TP's "write" & "writeln" procedures to do any output. It will output to
  18.   the remote and the local sides, just like if you were using the included
  19.   output routines in The DoorKit unit! The only limitation in this method
  20.   is that you can't put color/animation codes in the string, if you do they
  21.   will be displayed on both screens as normal text, you have to change the
  22.   colors by using the Set_Color, SetFore, or SetBack procedures.
  23.  
  24.   The syntax for using this method is:
  25.  
  26.     WRITE(SIO,'This is string 1.',' This is another...', ' A number:',12);
  27.           ^^^
  28.           ^^^-> The SIO file is the important element to use this method.
  29.   You basically use the SIO variable just like if it were an actual text
  30.   file. But certain procedures like "close,append,reset,rewrite,etc" don't
  31.   do anything when called with SIO. (Rewrite actually DOES do something,
  32.   but its handled automatically by this unit, and once Rewrite is called
  33.   once, successive calls don't do anything more). The SIO file does not
  34.   need to be closed, TP will do that on its own when the program exits.
  35.  
  36.   Do NOT try to use READLN() with the SIO variable, it'll do NOTHING, and
  37.   you'll get unpredicted results from it.}
  38.  
  39. INTERFACE
  40.  
  41. USES CRT, DOS, DOORKIT1;
  42.  
  43. VAR
  44.   IOBuf : ARRAY[0..511] OF CHAR;
  45.   SIO   : TEXT;
  46.  
  47. IMPLEMENTATION
  48.  
  49. {───────────────────────────────────────────────────────────────────────────}
  50. FUNCTION IOnothing(VAR F : TextRec) : INTEGER; Far;
  51. BEGIN
  52.   IOnothing := 0;
  53. END;
  54. {───────────────────────────────────────────────────────────────────────────}
  55. FUNCTION IOinput(VAR F : TextRec) : INTEGER; Far;
  56. BEGIN
  57.   IOinput := 0;
  58. END;
  59. {───────────────────────────────────────────────────────────────────────────}
  60. FUNCTION IOoutput(VAR F : TextRec) : INTEGER; Far;
  61. VAR
  62.   I : WORD;
  63. BEGIN
  64.   WITH F DO BEGIN
  65.     I := 0;
  66.     WHILE I < BufPos DO BEGIN
  67.       sWriteC(BufPtr^[I]);
  68.       INC(I);
  69.     END;
  70.     BufPos := 0;
  71.   END;
  72.   IOoutput := 0;
  73. END;
  74. {───────────────────────────────────────────────────────────────────────────}
  75. FUNCTION IOclose(VAR F : TextRec) : INTEGER; Far;
  76. BEGIN
  77.   IOclose := 0;
  78. END;
  79. {───────────────────────────────────────────────────────────────────────────}
  80. FUNCTION IOopen(VAR F : TextRec) : INTEGER; far;
  81. BEGIN
  82.   WITH F DO BEGIN
  83.     IF Mode = FMinput THEN BEGIN
  84.       InOutFunc := @IOnothing;
  85.       FlushFunc := @IOnothing;
  86.     END ELSE BEGIN
  87.       Mode := FMoutput;
  88.       InOutFunc := @IOoutput;
  89.       FlushFunc := @IOoutput;
  90.     END;
  91.     CloseFunc := @IOnothing;
  92.   END;
  93.   IOopen := 0;
  94. END;
  95. {───────────────────────────────────────────────────────────────────────────}
  96. PROCEDURE AssignIO;
  97. BEGIN
  98.   FILLCHAR(SIO, SIZEOF(SIO), 0);
  99.   WITH TextRec(SIO) DO BEGIN
  100.     Handle := $FFFF;
  101.     Mode := FMclosed;
  102.     BufSize := SIZEOF(Buffer);
  103.     BufPtr := @Buffer;
  104.     OpenFunc := @IOopen;
  105.   END;
  106. END;
  107. {───────────────────────────────────────────────────────────────────────────}
  108. BEGIN
  109.   AssignIO;
  110.   SETTEXTBUF(SIO,IOBuf);
  111.   REWRITE(SIO);
  112. END.
  113.